var debounce = {
    methods: {
        resizeHandle(){
            let self = this;
            function debounce(operate, delay){
                let time = null
                let timer = null
                let newTime = null
                function task(){
                    newTime =+new Date()
                    if(newTime - time < delay){
                        timer = setTimeout(task, delay)
                    }else{
                        operate()
                        timer = null
                    }
                    time = newTime
                }
                return function(){
                    time =+new Date()
                    if(!timer){
                        timer = setTimeout(task, delay)
                    }
                }
            }

            function methodEvents(){
                self.debounceEvents()
            }

            window.addEventListener('resize', debounce(methodEvents, 500), false)
        }
    }
}

export default debounce